/**
 * 搜索api服务接口
 * @author lian
 */
import type { Activity } from '@/common/types/activity'
import type { Projects } from '@/common/types/projects'

import useRequest from '@/common/composables/useReuqest'
import { SearchApi } from '@/common/constants/request-api'
import { Method } from '@/common/enum/request-methods'
import type { SearchType } from '@/common/types/request'

/**
 * 搜索
 * @param type 搜索类型
 * @param query 搜索内容
 * @author lian
 */
export const searchService = <T>(type: SearchType, query: string) => {
  return useRequest<T>({
    method: Method.GET,
    url: SearchApi.SEARCH,
    data: {
      type,
      query,
    },
  })
}

export const searchUserService = (query: string) => {
  return useRequest({
    method: Method.GET,
    url: SearchApi.SEARCH_USER,
    data: {
      query,
    },
  })
}

export const searchActivityService = (query: string) => {
  return useRequest<Activity[]>({
    method: Method.GET,
    url: SearchApi.SEARCH_ACTIVITY,
    data: {
      query,
    },
  })
}

export const searchProjectService = (query: string) => {
  return useRequest<Projects[]>({
    method: Method.GET,
    url: SearchApi.SEARCH_PROJECT,
    data: {
      query,
    },
  })
}
